#include "user.h"

void CUser::load_user_info(){
	m_MainNode = m_MainNode.openFileHelper("user.sv","SV");
	XMLNode child;

	child = m_MainNode.getChildNode("userName");
	m_UserName = child.getText();

	child = m_MainNode.getChildNode("userPassword");
	m_UserPassword = child.getText();

	child = m_MainNode.getChildNode("tray");
	const char * Tray = child.getText();
	if(!strcmp(Tray, "no")){
		m_Tray = false;
	}
	else{
		m_Tray = true;
	}
	child = m_MainNode.getChildNode("autoLogin");
	const char *  autoLogin = child.getText();
	if(!strcmp(autoLogin,"no")){
		m_AutoLogin = false;
	}
	else{
		m_AutoLogin = true;
	}

	child = m_MainNode.getChildNode("autoUpdate");
	const char * autoUpdate = child.getText();
	if(!strcmp(autoUpdate,"yes")){
		m_AutoUpdate = true;
	}
	else{
		m_AutoUpdate = false;
	}
	child = m_MainNode.getChildNode("suspend");
	const char * suspend = child.getText();
	if(!strcmp(suspend,"no")){
		m_suspend = false;
	}
	else{
		m_suspend = true;
	}
	child = m_MainNode.getChildNode("limitRate");
	const char * limitRate = child.getText();
	if(!strcmp(limitRate,"yes")){
		m_LimitRate = true;
	}
	else{
		m_LimitRate = false;
	}

	child = m_MainNode.getChildNode("maxRate");
	const char * maxRate = child.getText();
	int m_MaxRate = atoi(maxRate);

	child = m_MainNode.getChildNode("userCPUage");
	const char * userCPUage = child.getText();
	int m_UserCPUage = atoi(userCPUage);

	child = m_MainNode.getChildNode("userIdleTime");
	const char * userIdleTime = child.getText();
	long m_UserIdleTime = atol(userIdleTime);


	child = m_MainNode.getChildNode("autoBackUp");
	const char * autoBackUp = child.getText();
	if(!strcmp(autoUpdate,"yes")){
		m_AutoBackUp = true;
	}
	else{
		m_AutoBackUp = false;
	}

	child = m_MainNode.getChildNode("weekBackUp");
	const char * weekBackUp = child.getText();
	if(!strcmp(weekBackUp,"no")){
		m_WeekBackUp = false;
	}
	else{
		m_WeekBackUp = true;
	}


	child = m_MainNode.getChildNode("backTimes");
	const char * backTimes = child.getText();
	m_BackTimes = atoi(backTimes);

	child = m_MainNode.getChildNode("backWeeks");
	const char * backWeeks = child.getText();
	m_BackWeeks = atoi(backWeeks);

	child = m_MainNode.getChildNode("backWDay");
	const char * backWDay = child.getText();
	m_BackWDay = atoi(backWDay);

	child = m_MainNode.getChildNode("backHours");
	const char * backHours = child.getText();
	m_backHours = atoi(backHours);

	child = m_MainNode.getChildNode("backFinishHint");
	const char * backFinishHint = child.getText();
	if(!strcmp(backFinishHint,"yes")){
		m_BackFinishHint = true;
	}
	else{
		m_BackFinishHint = false;
	}


	child = m_MainNode.getChildNode("backStartHint");
	const char * backStartHint = child.getText();
	if(!strcmp(backStartHint, "yes")){
		m_BackStartHint = true;
	}
	else{
		m_BackStartHint = false;
	}


	child = m_MainNode.getChildNode("backSpaceHint");
	const char * backSpaceHint = child.getText();
	if(!strcmp(backSpaceHint,"yes")){
		m_BackSpaceHint = true;
	}
	else{
		m_BackSpaceHint = false;
	}
}

CUser g_User;